package pattern.observer.push;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by boot on 8/30/15.
 */
public class Subject {
    private List<Observer> observers = new ArrayList<Observer>();

    public void attach(Observer observer) {
        if (!observers.contains(observer))
            observers.add(observer);
    }

    public void detach(Observer observer) {
        observers.remove(observer);
    }

    protected void notifyObservers(String content) {
        for (Observer observer : observers) {
            observer.update(content);
        }
    }

}
